package test.test6_26;

/*
定义一个银行账户类Account, 3个属性, 用户名, 密码, 余额.
使用Getter/Setter方法实现以下功能:
要求用户名长度4-6位
密码长度6位
余额大于100
class Account{
private String userName;
private String password;
private double balance;
}
 */
public class Demo01 {
    public static void main(String[] args) {
        Account a = new Account("wzxwzx","123456",100);
        a.print();

    }
}

class Account {
    private String name;
    private String password;
    private double balance;
    /*
    要求用户名长度4-6位
    密码长度6位
    余额大于100
     */

    public Account() {//空参构造
    }

    public Account(String name, String password, double balance) {
        //有参构造
        setName(name);
        setPassword(password);
        setBalance(balance);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if (name.length() >= 4 && name.length() <= 6) {
            this.name = name;
        } else {
            System.out.println("用户名输入不合法");
        }

    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        if (password.length() == 6) {
            this.password = password;
        } else {
            System.out.println("用户密码输入不合法");
        }
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        if (balance >= 100) {
            this.balance = balance;
        }else {
            System.out.println("用户余额输入不合法");
        }
    }
    public void print() {
        System.out.println("用户名："+name+",用户密码："+password+",余额："+balance);
    }
}
